package com.ruoyi.slope.ai.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.slope.dataFile.domain.SlopeDataFile;
import com.ruoyi.slope.dataFile.service.ISlopeDataFileService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.slope.ai.domain.SlopeAiHljSlopeMonitoring;
import com.ruoyi.slope.ai.service.ISlopeAiHljSlopeMonitoringService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 黑龙江省公路边坡崩塌落石监控Controller
 * 
 * @author ruoyi
 * @date 2025-09-05
 */
@RestController
@RequestMapping("/ai/aiMonitoring")
public class SlopeAiHljSlopeMonitoringController extends BaseController
{
    @Autowired
    private ISlopeDataFileService slopeDataFileService;
    @Autowired
    private ISlopeAiHljSlopeMonitoringService slopeAiHljSlopeMonitoringService;

    /**
     * 查询黑龙江省公路边坡崩塌落石监控列表
     */
    @PreAuthorize("@ss.hasPermi('ai:aiMonitoring:list')")
    @GetMapping("/list")
    public TableDataInfo list(SlopeAiHljSlopeMonitoring slopeAiHljSlopeMonitoring)
    {
        startPage();
        List<SlopeAiHljSlopeMonitoring> list = slopeAiHljSlopeMonitoringService.selectSlopeAiHljSlopeMonitoringList(slopeAiHljSlopeMonitoring);
        return getDataTable(list);
    }

    /**
     * 导出黑龙江省公路边坡崩塌落石监控列表
     */
    @PreAuthorize("@ss.hasPermi('ai:aiMonitoring:export')")
    @Log(title = "黑龙江省公路边坡崩塌落石监控", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SlopeAiHljSlopeMonitoring slopeAiHljSlopeMonitoring)
    {
        List<SlopeAiHljSlopeMonitoring> list = slopeAiHljSlopeMonitoringService.selectSlopeAiHljSlopeMonitoringList(slopeAiHljSlopeMonitoring);
        ExcelUtil<SlopeAiHljSlopeMonitoring> util = new ExcelUtil<SlopeAiHljSlopeMonitoring>(SlopeAiHljSlopeMonitoring.class);
        String path = util.exportExcel(response, list, "黑龙江省公路边坡崩塌落石监控数据");
        SlopeDataFile slopeDataFile = new SlopeDataFile();
        slopeDataFile.setFileName(path);
        slopeDataFileService.insertSlopeDataFile(slopeDataFile);
    }

    /**
     * 获取黑龙江省公路边坡崩塌落石监控详细信息
     */
    @PreAuthorize("@ss.hasPermi('ai:aiMonitoring:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(slopeAiHljSlopeMonitoringService.selectSlopeAiHljSlopeMonitoringById(id));
    }

    /**
     * 新增黑龙江省公路边坡崩塌落石监控
     */
    @PreAuthorize("@ss.hasPermi('ai:aiMonitoring:add')")
    @Log(title = "黑龙江省公路边坡崩塌落石监控", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SlopeAiHljSlopeMonitoring slopeAiHljSlopeMonitoring)
    {
        return toAjax(slopeAiHljSlopeMonitoringService.insertSlopeAiHljSlopeMonitoring(slopeAiHljSlopeMonitoring));
    }

    /**
     * 修改黑龙江省公路边坡崩塌落石监控
     */
    @PreAuthorize("@ss.hasPermi('ai:aiMonitoring:edit')")
    @Log(title = "黑龙江省公路边坡崩塌落石监控", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SlopeAiHljSlopeMonitoring slopeAiHljSlopeMonitoring)
    {
        return toAjax(slopeAiHljSlopeMonitoringService.updateSlopeAiHljSlopeMonitoring(slopeAiHljSlopeMonitoring));
    }

    /**
     * 删除黑龙江省公路边坡崩塌落石监控
     */
    @PreAuthorize("@ss.hasPermi('ai:aiMonitoring:remove')")
    @Log(title = "黑龙江省公路边坡崩塌落石监控", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(slopeAiHljSlopeMonitoringService.deleteSlopeAiHljSlopeMonitoringByIds(ids));
    }
}
